package leetcode.剑指offer.剑指II;

import org.junit.Test;

import java.util.*;

/**
 * @author ：zsy
 * @date ：Created 2021/9/25 14:57
 * @description：
 */
public class 剑指_II_004_只出现一次的数字 {
    @Test
    public void test() {
        Solution solution = new Solution();
    }

    class Solution {
        public int singleNumber(int[] nums) {
            int res = 0;
            for (int i = 0; i < 32; i++) {
                int cnt = 0;
                for (int num : nums) {
                    cnt += num >> i & 1;
                }
                if (cnt % 3 != 0) {
                    res |= 1 << i;
                }
            }
            return res;
        }
    }
}
